package com.toocms.jinjuhang.ui.mine.payment.bank.code;

import android.os.Bundle;

import com.blankj.utilcode.util.StringUtils;
import com.toocms.jinjuhang.BR;
import com.toocms.jinjuhang.R;
import com.toocms.jinjuhang.databinding.DialogCodeBinding;
import com.toocms.tab.base.BaseDialogFragment;

/**
 * @Description:
 * @Author: Zero
 * @CreateDate: 2023/5/19 11:37
 */
public class CodeFgt extends BaseDialogFragment<DialogCodeBinding, CodeViewModel> {

    @Override
    protected void onFragmentCreated() {
        Bundle bundle = getArguments();
        if (bundle.containsKey("signid"))
            viewModel.signid = getArguments().getString("signid");
        if (bundle.containsKey("trade_no"))
            viewModel.trade_no = getArguments().getString("trade_no");
        if (bundle.containsKey("order_sn"))
            viewModel.order_sn = getArguments().getString("order_sn");
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.dialog_code;
    }

    @Override
    public int getVariableId() {
        return BR.codeViewModel;
    }

    @Override
    protected void viewObserver() {
        binding.code.setPasswordFullListener(code -> {
            if (!StringUtils.isEmpty(viewModel.trade_no))
                viewModel.ys_protocol_pay_confirm(code);
            else if (!StringUtils.isEmpty(viewModel.signid))
                viewModel.signConfirm(code);
        });
    }

    @Override
    protected boolean isMiddleDialog() {
        return true;
    }
}
